IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'spDOReportReleases_Create')
	BEGIN
		PRINT 'Dropping Procedure spDOReportReleases_Create'
		DROP  Procedure  spDOReportReleases_Create
	END

GO

PRINT 'Creating Procedure spDOReportReleases_Create'
GO
CREATE Procedure dbo.spDOReportReleases_Create
	( 	  
	  @d_folder varchar(50) = null, 
		@d_loc varchar(50) = null, 
		@d_user varchar(50) = null, 
		@d_status varchar(50) = null, 
		@d_match bit = null, 
		@d_exist bit = null, 
		@d_releasetype varchar(50) = null, 
		@d_releasereason varchar(500) = null, 
		@d_primaryattorney varchar(100) = null, 
		@d_accno varchar(50) = null, 
		@d_secondaryattorney varchar(100) = null, 
		@d_fileno varchar(50) = null, 
		@d_releasedate DateTime = null, 
		@d_doctype varchar(50) = null, 
		@d_returndate DateTime = null, 
		@d_stand varchar(50) = null, 
		@d_primaryattorneyletterreference varchar(50) = null, 
		@d_secondaryattorneyletterreference varchar(50) = null, 
		@d_suburb varchar(50) = null, 
		@d_customerletterreference varchar(50) = null, 
		@d_complex varchar(50) = null, 
		@d_custid varchar(50) = null, 
		@d_trackingnumber varchar(100) = null, 
		@d_custname1 varchar(100) = null, 
		@d_custname2 varchar(100) = null, 
		@d_lasttran DateTime = null, 
		@d_goldate DateTime = null, 
		@d_mbno varchar(50) = null, 
		@d_tdno varchar(50) = null, 
		@d_hogno varchar(50) = null, 
		@d_onwins varchar(50) = null, 
		@d_owninsno varchar(50) = null, 
		@d_lifecomp varchar(50) = null, 
		@d_lifeno varchar(50) = null, 
		@d_lifecess varchar(50) = null, 
		@d_lifewaiver DateTime = null, 
		@d_govtee varchar(50) = null, 
		@d_letsure DateTime = null, 
		@d_nhbrc bit = null, 
		@d_authpmt bit = null, 
		@d_gpadate DateTime = null, 
		@d_addendum varchar(50) = null, 
		@d_notes varchar(8000) = null, 
		@d_releaseNLP bit = null, 
		@d_notifyreturned bit = null, 
		@d_releasebatchnumber int = null, 
		@d_releasebatchclosed bit = null
	)
AS
  /* 
    ------------------------------------------------------------------------------
    - Change History
    - --------------
    - Date          Description
    ------------------------------------------------------------------------------
    - 2007/10/29    Initial version created
    ------------------------------------------------------------------------------
  */

	-- Declare the required variables

	-- Create the required new record
	INSERT INTO DOReportReleases
	  (
		d_folder,
			d_loc,
			d_user,
			d_status,
			d_match,
			d_exist,
			d_releasetype,
			d_releasereason,
			d_primaryattorney,
			d_accno,
			d_secondaryattorney,
			d_fileno,
			d_releasedate,
			d_doctype,
			d_returndate,
			d_stand,
			d_primaryattorneyletterreference,
			d_secondaryattorneyletterreference,
			d_suburb,
			d_customerletterreference,
			d_complex,
			d_custid,
			d_trackingnumber,
			d_custname1,
			d_custname2,
			d_lasttran,
			d_goldate,
			d_mbno,
			d_tdno,
			d_hogno,
			d_onwins,
			d_owninsno,
			d_lifecomp,
			d_lifeno,
			d_lifecess,
			d_lifewaiver,
			d_govtee,
			d_letsure,
			d_nhbrc,
			d_authpmt,
			d_gpadate,
			d_addendum,
			d_notes,
			d_releaseNLP,
			d_notifyreturned,
			d_releasebatchnumber,
			d_releasebatchclosed	  
	  )
	VALUES
	  (
		@d_folder,
			@d_loc,
			@d_user,
			@d_status,
			@d_match,
			@d_exist,
			@d_releasetype,
			@d_releasereason,
			@d_primaryattorney,
			@d_accno,
			@d_secondaryattorney,
			@d_fileno,
			@d_releasedate,
			@d_doctype,
			@d_returndate,
			@d_stand,
			@d_primaryattorneyletterreference,
			@d_secondaryattorneyletterreference,
			@d_suburb,
			@d_customerletterreference,
			@d_complex,
			@d_custid,
			@d_trackingnumber,
			@d_custname1,
			@d_custname2,
			@d_lasttran,
			@d_goldate,
			@d_mbno,
			@d_tdno,
			@d_hogno,
			@d_onwins,
			@d_owninsno,
			@d_lifecomp,
			@d_lifeno,
			@d_lifecess,
			@d_lifewaiver,
			@d_govtee,
			@d_letsure,
			@d_nhbrc,
			@d_authpmt,
			@d_gpadate,
			@d_addendum,
			@d_notes,
			@d_releaseNLP,
			@d_notifyreturned,
			@d_releasebatchnumber,
			@d_releasebatchclosed
	  )

	-- Handle any errors
	IF @@ERROR != 0
	BEGIN
		RAISERROR('spDOReportReleases_Create: Unable to Insert a new DOReportReleases', 10, 1)
		RETURN
	END

	-- Return the newly created ID
	SELECT	@@IDENTITY AS 'DOReportReleases_ID'

	-- Return to calling method
	RETURN 

GO
